import 'package:flutter/material.dart';
import 'package:shadcn_ui/shadcn_ui.dart';
import 'package:yuellyfactory/util/ViewUtil.dart';
import 'package:yuellyfactory/views/dto/Parameters.dart';

class ParameterDialog extends StatefulWidget {

  final List<Parameters> datas;
  final String title;
  const ParameterDialog({super.key,required this.title, required this.datas});

  @override
  State<ParameterDialog> createState() => _ParameterDialogState();
}

class _ParameterDialogState extends State<ParameterDialog> {
  @override
  Widget build(BuildContext context) {
    return ShadSheet(
      onClosing: (){
        
      },
      constraints: const BoxConstraints(maxWidth: 600 ),
      title:  Text(widget.title),
       
      child:  Card(
        color: Colors.white,
        child: Container(margin: const EdgeInsets.all(10),padding:  const EdgeInsets.all(10),
          child: Column(
            children: allViews(),
          ),
        ),
      ),
      
       
    );
  }

  List<Widget> allViews(){
    List<Widget> views=[];
    for(var i=0;i<widget.datas.length;i++){
      Parameters parm=widget.datas[i];
      views.add(Row(
        children: [
          Expanded( flex:1,child: Text(parm.key,style: TextStyle(fontSize: ViewUtil.fontSize(26)),)),
          SizedBox(width: ViewUtil.screenWidth(10),),
          Expanded( flex:2, child: Text(parm.value,textAlign: TextAlign.end,style: TextStyle(fontSize: ViewUtil.fontSize(26)))),
        ],

      ));
      if(i!=widget.datas.length-1){
        views.add(ViewUtil.lineView());
        views.add(SizedBox(height: ViewUtil.screenWidth(15),));
      }
    }

    return views;
  }
   
}
